home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_bas / vbcal32.zip / VBCAL32.FRM < prev    next >
Text File  |  1996-04-17  |  19KB  |  685 lines

  1. VERSION 4.00
  2. Begin VB.Form frmcalendar 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "VBCalendar"
  5.    ClientHeight    =   2715
  6.    ClientLeft      =   1350
  7.    ClientTop       =   1695
  8.    ClientWidth     =   4275
  9.    ControlBox      =   0   'False
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   0
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   3120
  21.    Icon            =   "VBCal32.frx":0000
  22.    Left            =   1290
  23.    LinkTopic       =   "Form1"
  24.    MaxButton       =   0   'False
  25.    ScaleHeight     =   2715
  26.    ScaleWidth      =   4275
  27.    Top             =   1350
  28.    Width           =   4395
  29.    Begin VB.CommandButton cmdAbout 
  30.       Caption         =   "About"
  31.       Height          =   255
  32.       Left            =   3000
  33.       TabIndex        =   5
  34.       Top             =   1920
  35.       Width           =   1215
  36.    End
  37.    Begin VB.ComboBox cboyear 
  38.       Height          =   315
  39.       Left            =   2880
  40.       Style           =   2  'Dropdown List
  41.       TabIndex        =   3
  42.       Top             =   240
  43.       Width           =   1215
  44.    End
  45.    Begin VB.ComboBox cbomonth 
  46.       Height          =   315
  47.       Left            =   120
  48.       Style           =   2  'Dropdown List
  49.       TabIndex        =   1
  50.       Top             =   240
  51.       Width           =   2415
  52.    End
  53.    Begin VB.CommandButton cmdcancel 
  54.       Appearance      =   0  'Flat
  55.       BackColor       =   &H80000005&
  56.       Cancel          =   -1  'True
  57.       Caption         =   "E&xit"
  58.       Height          =   345
  59.       Left            =   3000
  60.       TabIndex        =   39
  61.       Top             =   2280
  62.       Width           =   1215
  63.    End
  64.    Begin VB.CommandButton cmdok 
  65.       Appearance      =   0  'Flat
  66.       BackColor       =   &H80000005&
  67.       Caption         =   "&OK"
  68.       Default         =   -1  'True
  69.       Height          =   345
  70.       Left            =   3000
  71.       TabIndex        =   4
  72.       Top             =   1440
  73.       Width           =   1215
  74.    End
  75.    Begin VB.Label lbldate 
  76.       Alignment       =   2  'Center
  77.       BackStyle       =   0  'Transparent
  78.       ForeColor       =   &H00800000&
  79.       Height          =   615
  80.       Left            =   2880
  81.       TabIndex        =   38
  82.       Top             =   840
  83.       Width           =   1215
  84.    End
  85.    Begin VB.Label lblday 
  86.       Alignment       =   2  'Center
  87.       BackStyle       =   0  'Transparent
  88.       ForeColor       =   &H00800000&
  89.       Height          =   255
  90.       Left            =   2880
  91.       TabIndex        =   37
  92.       Top             =   645
  93.       Width           =   1215
  94.    End
  95.    Begin VB.Label lblnumber 
  96.       Alignment       =   2  'Center
  97.       BackStyle       =   0  'Transparent
  98.       Caption         =   "29"
  99.       Height          =   285
  100.       Index           =   28
  101.       Left            =   240
  102.       TabIndex        =   7
  103.       Top             =   2280
  104.       Width           =   300
  105.    End
  106.    Begin VB.Label lblnumber 
  107.       Alignment       =   2  'Center
  108.       BackStyle       =   0  'Transparent
  109.       Caption         =   "30"
  110.       Height          =   285
  111.       Index           =   29
  112.       Left            =   600
  113.       TabIndex        =   8
  114.       Top             =   2280
  115.       Width           =   300
  116.    End
  117.    Begin VB.Label lblnumber 
  118.       Alignment       =   2  'Center
  119.       BackStyle       =   0  'Transparent
  120.       Caption         =   "31"
  121.       Height          =   285
  122.       Index           =   30
  123.       Left            =   960
  124.       TabIndex        =   9
  125.       Top             =   2280
  126.       Width           =   300
  127.    End
  128.    Begin VB.Label lblnumber 
  129.       Alignment       =   2  'Center
  130.       BackStyle       =   0  'Transparent
  131.       Caption         =   "16"
  132.       Height          =   285
  133.       Index           =   15
  134.       Left            =   600
  135.       TabIndex        =   10
  136.       Top             =   1560
  137.       Width           =   300
  138.    End
  139.    Begin VB.Label lblnumber 
  140.       Alignment       =   2  'Center
  141.       BackStyle       =   0  'Transparent
  142.       Caption         =   "17"
  143.       Height          =   285
  144.       Index           =   16
  145.       Left            =   960
  146.       TabIndex        =   11
  147.       Top             =   1560
  148.       Width           =   300
  149.    End
  150.    Begin VB.Label lblnumber 
  151.       Alignment       =   2  'Center
  152.       BackStyle       =   0  'Transparent
  153.       Caption         =   "18"
  154.       Height          =   285
  155.       Index           =   17
  156.       Left            =   1320
  157.       TabIndex        =   12
  158.       Top             =   1560
  159.       Width           =   300
  160.    End
  161.    Begin VB.Label lblnumber 
  162.       Alignment       =   2  'Center
  163.       BackStyle       =   0  'Transparent
  164.       Caption         =   "19"
  165.       Height          =   285
  166.       Index           =   18
  167.       Left            =   1680
  168.       TabIndex        =   13
  169.       Top             =   1560
  170.       Width           =   300
  171.    End
  172.    Begin VB.Label lblnumber 
  173.       Alignment       =   2  'Center
  174.       BackStyle       =   0  'Transparent
  175.       Caption         =   "20"
  176.       Height          =   285
  177.       Index           =   19
  178.       Left            =   2040
  179.       TabIndex        =   36
  180.       Top             =   1560
  181.       Width           =   300
  182.    End
  183.    Begin VB.Label lblnumber 
  184.       Alignment       =   2  'Center
  185.       BackStyle       =   0  'Transparent
  186.       Caption         =   "21"
  187.       Height          =   285
  188.       Index           =   20
  189.       Left            =   2400
  190.       TabIndex        =   35
  191.       Top             =   1560
  192.       Width           =   300
  193.    End
  194.    Begin VB.Label lblnumber 
  195.       Alignment       =   2  'Center
  196.       BackStyle       =   0  'Transparent
  197.       Caption         =   "15"
  198.       Height          =   285
  199.       Index           =   14
  200.       Left            =   240
  201.       TabIndex        =   34
  202.       Top             =   1560
  203.       Width           =   300
  204.    End
  205.    Begin VB.Label lblnumber 
  206.       Alignment       =   2  'Center
  207.       BackStyle       =   0  'Transparent
  208.       Caption         =   "23"
  209.       Height          =   285
  210.       Index           =   22
  211.       Left            =   600
  212.       TabIndex        =   33
  213.       Top             =   1920
  214.       Width           =   300
  215.    End
  216.    Begin VB.Label lblnumber 
  217.       Alignment       =   2  'Center
  218.       BackStyle       =   0  'Transparent
  219.       Caption         =   "24"
  220.       Height          =   285
  221.       Index           =   23
  222.       Left            =   960
  223.       TabIndex        =   32
  224.       Top             =   1920
  225.       Width           =   300
  226.    End
  227.    Begin VB.Label lblnumber 
  228.       Alignment       =   2  'Center
  229.       BackStyle       =   0  'Transparent
  230.       Caption         =   "25"
  231.       Height          =   285
  232.       Index           =   24
  233.       Left            =   1320
  234.       TabIndex        =   31
  235.       Top             =   1920
  236.       Width           =   300
  237.    End
  238.    Begin VB.Label lblnumber 
  239.       Alignment       =   2  'Center
  240.       BackStyle       =   0  'Transparent
  241.       Caption         =   "26"
  242.       Height          =   285
  243.       Index           =   25
  244.       Left            =   1680
  245.       TabIndex        =   30
  246.       Top             =   1920
  247.       Width           =   300
  248.    End
  249.    Begin VB.Label lblnumber 
  250.       Alignment       =   2  'Center
  251.       BackStyle       =   0  'Transparent
  252.       Caption         =   "27"
  253.       Height          =   285
  254.       Index           =   26
  255.       Left            =   2040
  256.       TabIndex        =   29
  257.       Top             =   1920
  258.       Width           =   300
  259.    End
  260.    Begin VB.Label lblnumber 
  261.       Alignment       =   2  'Center
  262.       BackStyle       =   0  'Transparent
  263.       Caption         =   "28"
  264.       Height          =   285
  265.       Index           =   27
  266.       Left            =   2400
  267.       TabIndex        =   28
  268.       Top             =   1920
  269.       Width           =   300
  270.    End
  271.    Begin VB.Label lblnumber 
  272.       Alignment       =   2  'Center
  273.       BackStyle       =   0  'Transparent
  274.       Caption         =   "22"
  275.       Height          =   285
  276.       Index           =   21
  277.       Left            =   240
  278.       TabIndex        =   27
  279.       Top             =   1920
  280.       Width           =   300
  281.    End
  282.    Begin VB.Label lblnumber 
  283.       Alignment       =   2  'Center
  284.       BackStyle       =   0  'Transparent
  285.       Caption         =   "9"
  286.       Height          =   285
  287.       Index           =   8
  288.       Left            =   600
  289.       TabIndex        =   26
  290.       Top             =   1200
  291.       Width           =   300
  292.    End
  293.    Begin VB.Label lblnumber 
  294.       Alignment       =   2  'Center
  295.       BackStyle       =   0  'Transparent
  296.       Caption         =   "10"
  297.       Height          =   285
  298.       Index           =   9
  299.       Left            =   960
  300.       TabIndex        =   25
  301.       Top             =   1200
  302.       Width           =   300
  303.    End
  304.    Begin VB.Label lblnumber 
  305.       Alignment       =   2  'Center
  306.       BackStyle       =   0  'Transparent
  307.       Caption         =   "11"
  308.       Height          =   285
  309.       Index           =   10
  310.       Left            =   1320
  311.       TabIndex        =   24
  312.       Top             =   1200
  313.       Width           =   300
  314.    End
  315.    Begin VB.Label lblnumber 
  316.       Alignment       =   2  'Center
  317.       BackStyle       =   0  'Transparent
  318.       Caption         =   "12"
  319.       Height          =   285
  320.       Index           =   11
  321.       Left            =   1680
  322.       TabIndex        =   23
  323.       Top             =   1200
  324.       Width           =   300
  325.    End
  326.    Begin VB.Label lblnumber 
  327.       Alignment       =   2  'Center
  328.       BackStyle       =   0  'Transparent
  329.       Caption         =   "13"
  330.       Height          =   285
  331.       Index           =   12
  332.       Left            =   2040
  333.       TabIndex        =   22
  334.       Top             =   1200
  335.       Width           =   300
  336.    End
  337.    Begin VB.Label lblnumber 
  338.       Alignment       =   2  'Center
  339.       BackStyle       =   0  'Transparent
  340.       Caption         =   "14"
  341.       Height          =   285
  342.       Index           =   13
  343.       Left            =   2400
  344.       TabIndex        =   21
  345.       Top             =   1200
  346.       Width           =   300
  347.    End
  348.    Begin VB.Label lblnumber 
  349.       Alignment       =   2  'Center
  350.       BackStyle       =   0  'Transparent
  351.       Caption         =   "8"
  352.       Height          =   285
  353.       Index           =   7
  354.       Left            =   240
  355.       TabIndex        =   20
  356.       Top             =   1200
  357.       Width           =   300
  358.    End
  359.    Begin VB.Label lblnumber 
  360.       Alignment       =   2  'Center
  361.       BackStyle       =   0  'Transparent
  362.       Caption         =   "2"
  363.       Height          =   285
  364.       Index           =   1
  365.       Left            =   600
  366.       TabIndex        =   19
  367.       Top             =   840
  368.       Width           =   300
  369.    End
  370.    Begin VB.Label lblnumber 
  371.       Alignment       =   2  'Center
  372.       BackStyle       =   0  'Transparent
  373.       Caption         =   "3"
  374.       Height          =   285
  375.       Index           =   2
  376.       Left            =   960
  377.       TabIndex        =   18
  378.       Top             =   840
  379.       Width           =   300
  380.    End
  381.    Begin VB.Label lblnumber 
  382.       Alignment       =   2  'Center
  383.       BackStyle       =   0  'Transparent
  384.       Caption         =   "4"
  385.       Height          =   285
  386.       Index           =   3
  387.       Left            =   1320
  388.       TabIndex        =   17
  389.       Top             =   840
  390.       Width           =   300
  391.    End
  392.    Begin VB.Label lblnumber 
  393.       Alignment       =   2  'Center
  394.       BackStyle       =   0  'Transparent
  395.       Caption         =   "5"
  396.       Height          =   285
  397.       Index           =   4
  398.       Left            =   1680
  399.       TabIndex        =   16
  400.       Top             =   840
  401.       Width           =   300
  402.    End
  403.    Begin VB.Label lblnumber 
  404.       Alignment       =   2  'Center
  405.       BackStyle       =   0  'Transparent
  406.       Caption         =   "6"
  407.       Height          =   285
  408.       Index           =   5
  409.       Left            =   2040
  410.       TabIndex        =   15
  411.       Top             =   840
  412.       Width           =   300
  413.    End
  414.    Begin VB.Label lblnumber 
  415.       Alignment       =   2  'Center
  416.       BackStyle       =   0  'Transparent
  417.       Caption         =   "7"
  418.       Height          =   285
  419.       Index           =   6
  420.       Left            =   2400
  421.       TabIndex        =   14
  422.       Top             =   840
  423.       Width           =   300
  424.    End
  425.    Begin VB.Label lblnumber 
  426.       Alignment       =   2  'Center
  427.       BackStyle       =   0  'Transparent
  428.       Caption         =   "1"
  429.       Height          =   285
  430.       Index           =   0
  431.       Left            =   240
  432.       TabIndex        =   6
  433.       Top             =   840
  434.       Width           =   300
  435.    End
  436.    Begin VB.Shape Shape1 
  437.       Height          =   1935
  438.       Left            =   120
  439.       Top             =   720
  440.       Width           =   2655
  441.    End
  442.    Begin VB.Label Label1 
  443.       BackStyle       =   0  'Transparent
  444.       Caption         =   "&Year"
  445.       Height          =   255
  446.       Index           =   1
  447.       Left            =   2880
  448.       TabIndex        =   2
  449.       Top             =   0
  450.       Width           =   495
  451.    End
  452.    Begin VB.Label Label1 
  453.       BackStyle       =   0  'Transparent
  454.       Caption         =   "&Month"
  455.       Height          =   255
  456.       Index           =   0
  457.       Left            =   120
  458.       TabIndex        =   0
  459.       Top             =   0
  460.       Width           =   615
  461.    End
  462. End
  463. Attribute VB_Name = "frmcalendar"
  464. Attribute VB_Creatable = False
  465. Attribute VB_Exposed = False
  466. 'This code has been developed for EVERYONE'S use
  467. ' don't re-distribute this without ALL original files!!
  468. 'Phil Jones 1994
  469.  
  470. Option Explicit
  471. Dim selectedate%
  472.  
  473. Private Sub cbomonth_click()
  474. Call setday
  475. Call lblnumber_click(selectedate% - 1)
  476. End Sub
  477.  
  478. Private Sub cboyear_Click()
  479. Static once% ' get rid of first click event
  480. If Not once Then
  481.     once = True
  482.     Exit Sub
  483. End If
  484. Call cbomonth_click
  485.  
  486. End Sub
  487.  
  488. Private Sub checkdate(month1%, year1%)
  489. Dim i%, value%, date1$
  490.  
  491. For i% = 28 To 32
  492.     date1$ = (Str$(month1%) + "/" + Str$(i%) + "/" + Str$(year1%))
  493.         If IsDate(date1$) Then
  494.             value% = i%
  495.         Else
  496.             Call displaynumbers(value%)
  497.             Exit Sub
  498.         End If
  499. Next i%
  500. End Sub
  501.  
  502. Private Sub cmdAbout_Click()
  503. frmAbout.Show
  504. End Sub
  505.  
  506. Private Sub cmdcancel_Click()
  507. Unload frmcalendar
  508.  
  509. End Sub
  510.  
  511. Private Sub cmdok_Click()
  512. Dim month1%, day1%, year1%, date1$
  513. day1% = selectedate%
  514. month1% = cbomonth.ListIndex + 1
  515. year1% = cboyear.ListIndex + 1960
  516. date1$ = (Str$(month1%) + "/" + Str$(day1%) + "/" + Str$(year1%))
  517. date1$ = Format$(date1$, "general date")
  518.  
  519. MsgBox Format$(date1$, "long date") 'do whatever here to pass the date where
  520.                                     'you need it!
  521.  
  522. End Sub
  523.  
  524. Private Function determinemonth%()
  525. Dim i%
  526. i% = cbomonth.ListIndex 'which month is selected?
  527. determinemonth% = i% + 1
  528. End Function
  529.  
  530. Private Function determineyear%()
  531. Dim i%
  532. i% = cboyear.ListIndex 'which year was selected?
  533. If i% = -1 Then Exit Function 'problem!!
  534. determineyear% = CInt(Trim(cboyear.List(i%)))
  535. End Function
  536.  
  537. Private Sub displaynumbers(number%)
  538. Dim i%
  539. For i% = 28 To 30
  540.     lblnumber(i%).Visible = False
  541. Next i%
  542. For i% = 28 To number% - 1
  543.     lblnumber(i%).Visible = True
  544. Next i%
  545.  
  546. End Sub
  547.  
  548. Private Sub fillcbomonth()
  549. cbomonth.AddItem "January"
  550. cbomonth.AddItem "February"
  551. cbomonth.AddItem "March"
  552. cbomonth.AddItem "April"
  553. cbomonth.AddItem "May"
  554. cbomonth.AddItem "June"
  555. cbomonth.AddItem "July"
  556. cbomonth.AddItem "August"
  557. cbomonth.AddItem "September"
  558. cbomonth.AddItem "October"
  559. cbomonth.AddItem "November"
  560. cbomonth.AddItem "December"
  561.  
  562.  
  563. End Sub
  564.  
  565. Private Sub fillcboyear()
  566. Dim i%
  567. For i% = 1960 To 2060 'put whatever years tyou want here,
  568.     cboyear.AddItem Str$(i%) 'but don't forget to also change the code in setdate
  569. Next i%
  570.  
  571. End Sub
  572.  
  573. Private Sub Form_Load()
  574.  
  575. selectedate% = CInt(Format$(Now, "dd"))
  576.  
  577. 'fill month combo box
  578. Call fillcbomonth
  579.  
  580. 'fill year combo box
  581. Call fillcboyear
  582.  
  583. 'put current date and year im combo box
  584. Call setdate
  585.  
  586. 'set current name for day
  587. Dim r%, caption1$
  588. r% = WeekDay(Format$(Now, "general date"))
  589. If r% = 1 Then
  590.     caption1$ = "Sunday"
  591. ElseIf r% = 2 Then
  592.     caption1 = "Monday"
  593. ElseIf r% = 3 Then
  594.     caption1 = "Tuesday"
  595. ElseIf r% = 4 Then
  596.     caption1 = "Wednesday"
  597. ElseIf r% = 5 Then
  598.     caption1 = "Thursday"
  599. ElseIf r% = 6 Then
  600.     caption1 = "Friday"
  601. Else
  602.     caption1 = "Saturday"
  603. End If
  604. lblday.Caption = caption1$
  605.  
  606. End Sub
  607.  
  608. Private Sub lblnumber_click(Index As Integer)
  609. Dim i%
  610. On Error GoTo err1
  611. For i% = 0 To 30
  612.     lblnumber(i%).BorderStyle = 0
  613. Next i%
  614. If lblnumber(Index).BorderStyle = 1 Then
  615.     lblnumber(Index).BorderStyle = 0
  616. Else
  617.     lblnumber(Index).BorderStyle = 1
  618. End If
  619. selectedate% = Index + 1
  620. Dim month1%, day1%, year1%, date1$
  621. day1% = selectedate%
  622. month1% = cbomonth.ListIndex + 1
  623. year1% = cboyear.ListIndex + 1960
  624. date1$ = (Str$(month1%) + "/" + Str$(day1%) + "/" + Str$(year1%))
  625. 'date1$ = Format$(date1$, "general date")
  626. Dim r%
  627. Dim caption1$
  628. r% = WeekDay(date1$)
  629. If r% = 1 Then
  630.     caption1$ = "Sunday"
  631. ElseIf r% = 2 Then
  632.     caption1 = "Monday"
  633. ElseIf r% = 3 Then
  634.     caption1 = "Tuesday"
  635. ElseIf r% = 4 Then
  636.     caption1 = "Wednesday"
  637. ElseIf r% = 5 Then
  638.     caption1 = "Thursday"
  639. ElseIf r% = 6 Then
  640.     caption1 = "Friday"
  641. Else
  642.     caption1 = "Saturday"
  643. End If
  644. lblday.Caption = caption1$
  645. lbldate.Caption = Format$(date1$, "long date")
  646.  
  647. err1:
  648.     If Err = 0 Then Exit Sub
  649.     If Err = 13 Then
  650.         selectedate% = selectedate% - 1
  651.     Exit Sub
  652.     End If
  653.     End Sub
  654.  
  655. Private Sub setdate()
  656. 'since the list starts at 1960, this is 0, so we're going
  657. ' to get the date, and subtract 1960 from it, and use this
  658. 'as our starting listindex
  659. 'put whatever value you need to for the first year
  660. 'year
  661. Dim r%, i%
  662. r% = CInt(Format$(Now, "yyyy"))
  663. i% = r% - 1960
  664. cboyear.ListIndex = i%
  665.  
  666. 'month
  667. r% = CInt(Format$(Now, "mm"))
  668. cbomonth.ListIndex = (r% - 1)
  669.  
  670. 'day
  671. r% = CInt(Format$(Now, "dd"))
  672. lblnumber(r% - 1).BorderStyle = 1
  673. selectedate% = r%
  674.  
  675. End Sub
  676.  
  677. Private Sub setday()
  678. Dim month1%, year1%
  679. month1% = determinemonth()
  680. year1% = determineyear()
  681. Call checkdate(month1%, year1%)
  682.  
  683. End Sub
  684.  
  685.